﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.Runtime.Serialization;

namespace PMisuseAn.behaviour.model
{
    [Serializable()]
    public class VulnerableAggTransmission : ISerializable
    {
        public Attribute h_att;
        public State h_message_s;
        public Transition h_message_t;
        public List<Object> h_parameterisedContextInstances;
        public Dictionary<Dictionary<Agent, Agent>, ListDictionary> h_sendReceiveContextAgent;

        public Agent h_sendAgent;
        public Agent h_receiveAgent;
        public Agent h_subjectAgent;
        public string inferenceStatement;
        public int historySeqNo;
        public string originalMessage;
        public string originalContext;

        //Default constructor
        public VulnerableAggTransmission(Attribute h_att_,
            State h_message_s_,
            Transition h_message_t_,
            List<Object> h_parameterisedContextInstances_,
            Dictionary<Dictionary<Agent, Agent>, ListDictionary> h_sendReceiveContextAgent_,

            Agent h_sendAgent_,
            Agent h_receiveAgent_,
            Agent h_subjectAgent_,
            string inferenceStatement_,
            int historySeqNo_,
            string originalMessage_,
            string originalContext_)
        {
            h_att =h_att_;
            h_message_s =h_message_s_;
            h_message_t = h_message_t_;
            h_parameterisedContextInstances =h_parameterisedContextInstances_;
            h_sendReceiveContextAgent = h_sendReceiveContextAgent_;

            h_sendAgent = h_sendAgent_;
            h_receiveAgent = h_receiveAgent_;
            h_subjectAgent = h_subjectAgent_;
            inferenceStatement = inferenceStatement_;
            historySeqNo = historySeqNo_;
            originalMessage = originalMessage_;
            originalContext = originalContext_;
        }

        //Deserialization constructor.
        public VulnerableAggTransmission(SerializationInfo info, StreamingContext ctxt)
        {
            //Get the values from info and assign them to the appropriate properties
            h_att = (Attribute)info.GetValue("h_att", typeof(Attribute));
            h_message_s = (State)info.GetValue("h_message_s", typeof(State));
            h_message_t = (Transition)info.GetValue("h_message_t", typeof(Transition));
            h_parameterisedContextInstances = (List<Object>)info.GetValue("h_parameterisedContextInstances", typeof(List<Object>));
            h_sendReceiveContextAgent = (Dictionary<Dictionary<Agent, Agent>, ListDictionary>)info.GetValue("h_sendReceiveContextAgent", typeof(Dictionary<Dictionary<Agent, Agent>, ListDictionary>));
            h_sendAgent = (Agent)info.GetValue("h_sendAgent", typeof(Agent));
            h_receiveAgent = (Agent)info.GetValue("h_receiveAgent", typeof(Agent));
            h_subjectAgent = (Agent)info.GetValue("h_subjectAgent", typeof(Agent));
            inferenceStatement = (string)info.GetValue("inferenceStatement", typeof(string));
            historySeqNo = (int)info.GetValue("historySeqNo", typeof(int));
            originalMessage = (string)info.GetValue("originalMessage", typeof(string));
            originalContext = (string)info.GetValue("originalContext", typeof(string));
        }
        
        //Serialization function.
        public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
        {
            info.AddValue("h_att", h_att);
            info.AddValue("h_message_s", h_message_s);
            info.AddValue("h_message_t", h_message_t);
            info.AddValue("h_parameterisedContextInstances", h_parameterisedContextInstances);
            info.AddValue("h_sendReceiveContextAgent", h_sendReceiveContextAgent);
            info.AddValue("h_sendAgent", h_sendAgent);
            info.AddValue("h_receiveAgent", h_receiveAgent);
            info.AddValue("h_subjectAgent", h_subjectAgent);
            info.AddValue("inferenceStatement", inferenceStatement);
            info.AddValue("historySeqNo", historySeqNo);
            info.AddValue("originalMessage", originalMessage);
            info.AddValue("originalContext", originalContext);
        }

    }
}
